Software-defined Radio and GNU Radio

Software-defined Radio

Traditional RF experiment involves RF circuit design, Down-Sampling, ADC, then processing the signal. The following figure is the diagram of Superheterodyne receiver. The limited ADC processing speed is the reason that making the circuit complicated.

Superheterodyne receiver

Nowadays, powerful ADC together with downsampling chip can directly convert the samples from the antenna to digital signal for PC to process. Also, the PC is then in charge of all the signal processing work.

sdr receiver

Universal Software Radio Peripheral (USRP) is such a device which samples RF waveform and converts samples to digital signals.

usrp

GNU Radio

GNU Radio is a free & open-source software development toolkit that provides signal processing blocks to implement software radios. It can be used with readily-available low-cost external RF hardware to create software-defined radios, or without hardware in a simulation-like environment. It is widely used in research, industry, academia, government, and hobbyist environments to support both wireless communications research and real-world radio systems.

The following image is an example flowgraph of a CDMA transmitter.

../../../../_images/cdma-tx-gnuradio.png

Necessary Knowledge about GNU Radio

If you are a student who is taking IoT course, the following will introduce some basic knowledge you many need to know to complete the lab. If you are a reader, I suggest you to visit GNU Radio and go through their wonderful tutorial.

As shown in the block diagram above, there is a canvas where you can put a lot of functional blocks. By default, GNU Radio comes with multiple often-to-use blocks, such as Math blocks, AM/FM modulation and demodulation blocks. The black arrow connecting two blocks indicates the data flow coming from one to to another. If an arrow is black, the connection is good in syntax, otherwise, the arrow head is red.

Typically, data flows out from a port on the right and flows in to a port on the left. The color of the port indicates the data type. E.g., orange - 32-bit float, blue - complex number (two 32-bit float), purple - 8-bit bytes, yellow - 16-bit short, green 32-bit integer.

GNU Radio processes data following a data pipe line. Each time, some number of data samples will be generated and travel from one block to another. The number of samples are stored in a list, and the number of samples may not be the same at each time. When a list of samples reaches a block, the list will be processed by the block’s `work` function. It’s not guaranteed that the work function complete the process of all samples in the list, so it’s allowed to return a half-way complete result. But for the lab, you don’t need to think about that. You should process all the input data and return the length.

In our lab, you are supposed to implement a python block. The block comes with a declaration of python class, and you can add customized member attributes (or member variables if you perfer). The class has a `work` function, which is called by the GNURadio. Input sample list(s) is(are) stored in a list named `input_items`. Output samples should be placed in a list name `output_items`. The shape of `input_items` is `[num of inputs x num of samples]`, and the shape of `output_items` is `[num of outputs x num of samples]`. For example, if you are working on a three-input-two-output block, `input_items` is of shape \(3xm\) and the output should be of shape \(2xn\) . \(m\) and \(n\) are unknown integers which also changes in each function call. The return value of the `work` function is the length of output list, i.e., \(2xn\), because you need to explicitly tell GNU Radio how many samples in the `output_items` are good to use.